package com.kmzx.gen.signs.dto;

import com.kmzx.gen.signs.config.XStreamInitializer;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamAsAttribute;

/**
 * @Project seagate
 * @Author: carol
 * @Date: 2020/7/20-16:31
 */

@XStreamAlias("ENT312Message")
public class ENT312Message {

    @XStreamAsAttribute
    @XStreamAlias("xmlns")
    public String xmlns;


    @XStreamAsAttribute
    @XStreamAlias("guid")
    public String guid;


    @XStreamAsAttribute
    @XStreamAlias("version")
    public String version;


    @XStreamAlias("OrderReturn")
    public OrderReturn OrderReturn;

    public String getXmlns() {
        return xmlns;
    }

    public ENT312Message setXmlns(String xmlns) {
        this.xmlns = xmlns;
        return this;
    }

    public String getGuid() {
        return guid;
    }

    public ENT312Message setGuid(String guid) {
        this.guid = guid;
        return this;
    }

    public String getVersion() {
        return version;
    }

    public ENT312Message setVersion(String version) {
        this.version = version;
        return this;
    }

    public com.kmzx.gen.signs.dto.OrderReturn getOrderReturn() {
        return OrderReturn;
    }

    public ENT312Message setOrderReturn(com.kmzx.gen.signs.dto.OrderReturn orderReturn) {
        OrderReturn = orderReturn;
        return this;
    }

    public String toXML() {
        XStream xstream = XStreamInitializer.getInstance();
        //涉及到服务商模式的两个参数，在为空值时置为null，以免在请求时将空值传给微信服务器
        xstream.processAnnotations(this.getClass());
        return xstream.toXML(this);
    }


    public static ENT312Message fromXML(String xmlString) {
        XStream xstream = XStreamInitializer.getInstance();
        xstream.processAnnotations(ENT312Message.class);
        ENT312Message result = (ENT312Message) xstream.fromXML(xmlString);
        return result;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("ENT312Message{");
        sb.append("xmlns='").append(xmlns).append('\'');
        sb.append(", guid='").append(guid).append('\'');
        sb.append(", version='").append(version).append('\'');
        sb.append(", orderReturn=").append(OrderReturn);
        sb.append('}');
        return sb.toString();
    }
}
